<?php defined( '_JEXEC') or die( 'Restricted access'); // No direct access; ?>
<script type="text/javascript">
function toggleMp3FileInput(){	
	var radios = document.getElementsByName("newmp3");
	
	document.getElementById('file').disabled = (radios[0].checked);
	document.getElementById('mp3player').disabled = !(radios[0].checked);
}
</script>
<div class="subhead">
    <form enctype="multipart/form-data" action="index.php?option=com_volunteer&task=updatefile" method="POST">
		<input type="hidden" name="fileid" value="<?php echo JRequest::getVar('fileid') ;?>" />
		
            <p>
                <h3>
                    Update file's detail:
                </h3>
            </p>
            <p>
                <table border="0" cellspacing="0">
                    <tr>
                        <td width="">
                            Filename <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td width="">
                            <input name="name" type="text" size="45" value="<?php echo $this->file->name; ?>" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Description <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td>
                            <textarea name="description" maxlength="1000" cols="45" rows="5"><?php echo $this->file->description; ?></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Location <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td>
                            <select name="location">
                                <?php foreach($this->locations as $item) : ?>
                                    <option value="<?php echo $item->id; ?>" <?php if($item->id == $this->file->location_id) { ?>selected="selected"<?php }; ?>>
                                        <?php echo $item->name; ?>
                                    </option>
                                    <?php endforeach; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Timespan <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td>
                            <select name="timespan">
                                <?php foreach($this->timespans as $item) : ?>
                                    <option value="<?php echo $item->id; ?>" <?php if($item->id == $this->file->timespan_id) { ?>selected="selected"<?php }; ?>>
                                        <?php echo $item->name; ?>
                                    </option>
                                    <?php endforeach; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Industry <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td>
                            <select name="industry">
                                <?php foreach($this->industries as $item) : ?>
                                    <option value="<?php echo $item->id; ?>" <?php if($item->id == $this->file->industry_id) { ?>selected="selected"<?php }; ?>>
                                        <?php echo $item->name; ?>
                                    </option>
                                    <?php endforeach; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Keyword(s)
                        </td>
                        <td>
                            <textarea name="keywords" id="txtKeywords" cols="45" rows="2"><?php echo $this->keywords ?></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            File <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
						<td>
							<input type="radio" name="newmp3" id="newmp3" value="current" <?php if($this->newmp3 == 'current'): ?>CHECKED<?php endif; ?> onChange="javascript:toggleMp3FileInput();"> Keep current mp3 file<br />
							<object class="playerpreview" type="application/x-shockwave-flash" data="<?php $this->baseurl; ?>components/com_volunteer/mp3player/player_mp3_mini.swf"
								width="200" height="20" id="mp3player">
									<param name="movie" value="<?php $this->baseurl; ?>components/com_volunteer/mp3player/player_mp3_mini.swf" />
									<param name="bgcolor" value="#492F92" />
									<param name="FlashVars" value="mp3=<?php echo $this->linkToFile; ?>" />
								</object><br/>
							<input type="radio" name="newmp3" id="newmp3" value="new" <?php if($this->newmp3 == 'new'): ?>CHECKED<?php endif; ?> onChange="javascript:toggleMp3FileInput();"> Change to a new mp3 file<br />
							<input type="file" name="file" size="45" id="file" <?php if($this->newmp3 == 'current'): ?>disabled="disabled"<?php endif; ?> />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Acknowledgement <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" />
                        </td>
                        <td>
                            <textarea name="acknowledgement" maxlength="1000" cols="45" rows="5"><?php echo $this->file->acknowledgement; ?></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" value="Update file" />
							<input type="button" value="Cancel" onclick="javascript:window.location='<?php echo JRoute::_('index.php?option=com_volunteer&view=searchfile') ;?>';" />
                        </td>
                        <td>
                            <img src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/images/MandatoryIcon.gif" /> Mandatory fields
                        </td>
                    </tr>
                </table>
    </form>
</div>
	<script language="javascript" type="text/javascript" src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/js/actb.js"></script>
	<script language="javascript" type="text/javascript" src="<?php $this->baseurl; ?>templates/gippslandsitetemplate3/js/common.js"></script>
	<script>
		// source: http://www.codeproject.com/KB/scripting/jsactb.aspx
		var customarray=new Array(); //'an apple','alligator','elephant','pear','kingbird','kingbolt', 'kingcraft','kingcup','kingdom','kingfisher','kingpin');
		
	<?php
		$cnt = 0;
		foreach($this->keywordList as $keyword)
		{		
	?>
		customarray[<?php echo $cnt; ?>] = '<?php echo $keyword->keyword; ?>';
	<?php
			$cnt++;
		}
	?>
		var obj = actb(document.getElementById('txtKeywords'),customarray);
		//setTimeout(function(){obj.actb_keywords = custom2;},10000);
	</script>